app.activeDocument.layerSets.add() adds a new layerSet to the document. So yellow would be a layerSet which doesn't have a kind property. You can only set the kind property of artLayers to TEXT( NORMAL is the default ). To add any other layer type you must use Action Manager. var yellowSet = app.activeDocument.layerSets.add(); yellowSet.name ='Yellow layer set'; newAdjustmentLevelsLayer(undefined,undefined,undefined,126, 255); app.activeDocument.activeLayer.name = 'My levels layer'; function newAdjustmentLevelsLayer( blackIn, whiteIn, gamma, blackOut, whiteOut ) { var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putClass( stringIDToTypeID( "adjustmentLayer" ) ); desc.putReference( stringIDToTypeID( "null" ), ref ); var classDesc = new ActionDescriptor(); classDesc.putClass( stringIDToTypeID( "type" ), stringIDToTypeID( "levels" ) ); desc.putObject( stringIDToTypeID( "using" ), stringIDToTypeID( "adjustmentLayer" ), classDesc ); executeAction( stringIDToTypeID( "make" ), desc, DialogModes.NO ); var desc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( stringIDToTypeID( "adjustmentLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) ); desc.putReference( stringIDToTypeID( "null" ), ref ); var adjustmentDesc = new ActionDescriptor(); var list = new ActionList(); var levelDesc = new ActionDescriptor(); var ref = new ActionReference(); ref.putEnumerated( stringIDToTypeID( "channel" ), stringIDToTypeID( "channel" ), stringIDToTypeID( "composite" ) ); levelDesc.putReference( stringIDToTypeID( "channel" ), ref ); var inputList = new ActionList(); inputList.putInteger( blackIn!=undefined?blackIn:0 ); inputList.putInteger( whiteIn!=undefined?whiteIn:255 ); levelDesc.putList( stringIDToTypeID( "input" ), inputList ); levelDesc.putDouble(stringIDToTypeID( "gamma" ), gamma!=undefined?gamma:1.0 ); var outputList = new ActionList(); outputList.putInteger( blackOut!=undefined?blackOut:0 ); outputList.putInteger( whiteOut!=undefined?whiteOut:255 ); levelDesc.putList( stringIDToTypeID( "output" ), outputList ); list.putObject( stringIDToTypeID( "levelsAdjustment" ), levelDesc ); adjustmentDesc.putList( stringIDToTypeID( "adjustment" ), list ); desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "levels" ), adjustmentDesc ); executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO ); };
... View more